<template>
  <div class="standardSetDetail">
    <el-row
      v-if="scoreDimType != '20'"
      :class="isIndexOf > -1 ? 'advice' : 'notAdvice'"
    >
      <i class="el-icon-info"></i>
      <span class="iconText"
        >此项指标{{ responsibility === '通用指标' ? '为' : '责任主体为：'
        }}{{ responsibility }}，{{ isIndexOf > -1 ? '' : '不' }}建议选用。</span
      >
    </el-row>
    <el-row class="standardSetContent">
      <el-form
        :model="standardSetForm"
        :rules="standardRules"
        label-width="90px"
        ref="standardSetForm"
      >
        <el-form-item label="选用方案:">
          <el-radio-group v-model="planId" @change="changePlan">
            <el-radio v-for="(v, i) in planList" :key="i" :label="v.id">{{
              v.name
            }}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="指标名称:">
          <span class="explain">{{ standardSetInfo.name }}</span>
        </el-form-item>
        <el-form-item label="指标维度:">
          <span class="explain">{{ standardSetInfo.dimName }}</span>
        </el-form-item>
        <el-form-item label="评价标准:" prop="evaluateStandard">
          <el-input
            type="textarea"
            placeholder="请输入评价标准"
            :autosize="{ minRows: 2, maxRows: 4 }"
            v-model="standardSetForm.evaluateStandard"
            style="width: 514px"
            maxlength="200"
            show-word-limit
          ></el-input>
        </el-form-item>
        <el-form-item
          v-if="standardSetInfo.name != '一票否决'"
          label="指标分值:"
          prop="score"
        >
          <el-input
            v-model.number="standardSetForm.score"
            style="width: 64px"
          ></el-input
          >&ensp;分
        </el-form-item>
        <el-row>
          <el-col
            style="
              width: 78px;
              text-align: right;
              margin-right: 12px;
              font-size: 14px;
              color: #333333;
              height: 24px;
              line-height: 24px;
            "
            >评分办法:</el-col
          >
          <el-col style="width: 600px">
            <div
              class="explain"
              v-if="standardSetForm.evaluateCalculateType === 1"
              style="margin-bottom: 14px"
            >
              <div
                v-html="standardSetForm.methods[0].calculateMethod"
                class="getExplain"
              ></div>
            </div>
            <div
              class="explain"
              v-if="standardSetForm.evaluateCalculateType === 2"
            >
              <div
                v-html="
                  standardSetForm.methods[0].calculateMethod &&
                  standardSetForm.methods[0].calculateMethod.replace('%d', '')
                "
                class="getExplain"
              ></div>
              <div
                style="margin-top: 10px"
                v-for="(v, i) in standardSetForm.methods"
                :key="i"
              >
                扣分:
                <el-form-item
                  :prop="`methods[${i}].reduceScore`"
                  :rules="standardRules.reduceScore"
                  label-width="0"
                  style="display: inline-block; width: 150px"
                >
                  <el-input
                    v-model="v.reduceScore"
                    style="width: 64px"
                  ></el-input>
                </el-form-item>
              </div>
            </div>
            <div
              class="explain"
              v-if="standardSetForm.evaluateCalculateType === 3"
            >
              <div
                v-html="standardSetForm.methods[0].calculateMethod"
                style="margin-bottom: 14px"
                class="getExplain"
              ></div>
              <div v-for="(v, i) in standardSetForm.methods" :key="i">
                <div v-if="i <= 1">
                  {{ v.extend }}，扣
                  <el-form-item
                    :prop="`methods[${i}].reduceScore`"
                    :rules="standardRules.reduceScore"
                    label-width="0"
                    style="display: inline-block; width: 150px"
                  >
                    <el-input
                      v-model="v.reduceScore"
                      style="width: 64px"
                    ></el-input
                    >&ensp;分;
                  </el-form-item>
                </div>
                <div v-else>
                  {{ v.extend }}，定级
                  <el-form-item
                    :prop="`methods[${i}].gradeLevel`"
                    :rules="standardRules.gradeLevel"
                    label-width="0"
                    style="display: inline-block; width: 150px"
                  >
                    <el-select
                      v-model="v.gradeLevel"
                      filterable
                      placeholder="请选择"
                      clearable
                      style="width: 110px"
                    >
                      <el-option
                        v-for="item in selectLevel"
                        :key="item.id"
                        :label="item.gradeLevel"
                        :value="item.gradeLevel"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </div>
              </div>
            </div>
            <div
              class="explain"
              v-if="standardSetForm.evaluateCalculateType === 4"
            >
              <div
                v-html="standardSetForm.methods[0].calculateMethod"
                class="getExplain"
              ></div>
              <div style="margin-top: 10px">
                扣分
                <el-button
                  type="primary"
                  icon="iconfont iconshezhi"
                  class="commonBut saveBtn funComBut"
                  @click="reduceSet()"
                  ><span class="opetareText">扣分配置</span></el-button
                >
              </div>
              <div style="margin-top: 10px; margin-bottom: 10px">
                <p class="getExplain">
                  {{ standardSetForm.evaluateMethodRate }}≥100%，不扣分
                </p>
                <div
                  v-if="
                    standardSetForm.methods.length > 1 ||
                    (standardSetForm.methods[0].startCondition &&
                      standardSetForm.methods[0].endCondition)
                  "
                >
                  <p
                    v-for="(item, index) in standardSetForm.methods"
                    :key="index"
                    class="getExplain"
                  >
                    {{ item.startCondition + '%' }} ＞
                    {{ standardSetForm.evaluateMethodRate }} ≥
                    {{ item.endCondition + '%' }}，扣{{ item.score }}分
                  </p>
                </div>
              </div>
            </div>
            <div
              class="explain"
              v-if="standardSetForm.evaluateCalculateType === 5"
            >
              <div
                v-html="standardSetForm.methods[0].calculateMethod"
                class="getExplain"
              ></div>
              <div style="margin-top: 10px">
                <div class="everyRate">
                  <el-form-item
                    class="subLevel"
                    label-width="0"
                    :prop="`methods[0].startCondition`"
                    :rules="standardRules.startCondition"
                  >
                    <el-input
                      v-model="standardSetForm.methods[0].startCondition"
                    ></el-input>
                  </el-form-item>
                  %
                  <div class="score">
                    ≥ {{ standardSetForm.evaluateMethodRate }} ≥
                  </div>
                  <el-form-item
                    :prop="`methods[0].endCondition`"
                    class="subLevel"
                    :rules="standardRules.endCondition"
                    label-width="0"
                  >
                    <el-input
                      v-model="standardSetForm.methods[0].endCondition"
                    ></el-input>
                  </el-form-item>
                  % ：不扣分；
                </div>
                <div class="everyRate">
                  <el-form-item
                    class="subLevel"
                    label-width="0"
                    :prop="`methods[1].startCondition`"
                    :rules="standardRules.startCondition"
                  >
                    <el-input
                      v-model="standardSetForm.methods[1].startCondition"
                    ></el-input>
                  </el-form-item>
                  %
                  <div class="score">
                    ＞{{ standardSetForm.evaluateMethodRate }} ≥
                  </div>
                  <el-form-item
                    :prop="`methods[1].endCondition`"
                    class="subLevel"
                    :rules="standardRules.endCondition"
                    label-width="0"
                  >
                    <el-input
                      v-model="standardSetForm.methods[1].endCondition"
                    ></el-input>
                  </el-form-item>
                  % ：扣分=（1 -
                  {{ standardSetForm.evaluateMethodRate }}）*分值；
                </div>
                <div class="everyRate">
                  <el-form-item
                    class="subLevel"
                    label-width="0"
                    :prop="`methods[2].startCondition`"
                    :rules="standardRules.startCondition"
                  >
                    <el-input
                      v-model="standardSetForm.methods[2].startCondition"
                    ></el-input>
                  </el-form-item>
                  %
                  <div class="score">
                    ≥ {{ standardSetForm.evaluateMethodRate }}＞
                  </div>
                  <el-form-item
                    :prop="`methods[2].endCondition`"
                    class="subLevel"
                    :rules="standardRules.endCondition"
                    label-width="0"
                  >
                    <el-input
                      v-model="standardSetForm.methods[2].endCondition"
                    ></el-input>
                  </el-form-item>
                  % ：扣分=[ 1 -（{{
                    standardSetForm.methods[2].startCondition + '%'
                  }}
                  - {{ standardSetForm.evaluateMethodRate }}）]*分值；
                </div>
                <div class="everyRate">
                  <div class="score">
                    {{ standardSetForm.evaluateMethodRate }} ＞
                  </div>
                  <el-form-item
                    :prop="`methods[2].startCondition`"
                    class="subLevel"
                    :rules="standardRules.startCondition"
                    label-width="0"
                  >
                    <el-input
                      v-model="standardSetForm.methods[3].endCondition"
                    ></el-input>
                  </el-form-item>
                  % ：分值扣完。
                </div>
              </div>
            </div>
          </el-col>
        </el-row>
        <el-form-item label="修复方式:" prop="repairTips">
          <el-input
            type="textarea"
            placeholder="请输入修复方式"
            :autosize="{ minRows: 2, maxRows: 8 }"
            v-model="standardSetForm.repairTips"
            style="width: 514px"
            maxlength="200"
            show-word-limit
          ></el-input>
        </el-form-item>
        <el-form-item label="参考条例:" prop="referenceRules">
          <el-input
            type="textarea"
            placeholder="请输入参考条例"
            :autosize="{ minRows: 2, maxRows: 8 }"
            v-model="standardSetForm.referenceRules"
            style="width: 514px"
            maxlength="200"
            show-word-limit
          ></el-input>
        </el-form-item>
      </el-form>
      <div>
        <el-button
          v-if="isShowUpdate"
          type="primary"
          @click="saveSet('standardSetForm')"
          v-sdc
          class="commonBut saveBtn funComBut"
          style="width: 136px; margin-left: 90px"
          >保存</el-button
        >
        <span class="setInfo"
          >上次保存时间：{{ standardSetForm.saveTime || '--' }}</span
        >
      </div>
    </el-row>
    <el-dialog
      title="扣分配置"
      :visible.sync="reduceVisible"
      :close-on-click-modal="false"
      @closed="closeDialog"
      width="625px"
      :modal-append-to-body="false"
      class="dialogForm"
      :append-to-body="true"
    >
      <el-form :model="reduceForm" ref="formRef" :rules="reduceFormRules">
        <el-row style="margin-bottom: 16px" class="title">
          <span class="titleScore"
            >{{ standardSetForm.evaluateMethodRate }}区间（单位%）</span
          >
          <span class="titleLevel">扣分值</span>
          <span class="titleAction"></span>
        </el-row>
        <el-row v-for="(item, index) in reduceForm.setList" :key="index">
          <div class="titleScore">
            <el-form-item class="subLevel">
              <el-input
                disabled="true"
                v-model="item.startCondition"
              ></el-input>
            </el-form-item>
            <div class="score">
              ＞ {{ standardSetForm.evaluateMethodRate }} ≥
            </div>
            <el-form-item
              :prop="'setList.' + index + '.endCondition'"
              class="subLevel"
              :rules="reduceFormRules.endCondition"
            >
              <el-input
                @input="changeRate(index)"
                v-model="item.endCondition"
              ></el-input>
            </el-form-item>
          </div>
          <el-form-item
            :prop="'setList.' + index + '.reduceScore'"
            class="titleLevel"
            :rules="reduceFormRules.reduceScore"
          >
            <el-input v-model="item.reduceScore"></el-input>
          </el-form-item>
          <div
            v-if="index !== 0"
            style="font-size: 14px; color: #e42722"
            class="titleAction"
            @click="delRate(index)"
          >
            删除
          </div>
          <div
            v-else
            style="font-size: 14px; color: #e42722"
            class="titleAction"
          ></div>
        </el-row>
      </el-form>
      <el-row @click.native="addLevel" class="addLevel">
        <span style="font-size: 25px">+</span>
        <span style="position: relative; top: -4px">添加区间</span>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button @click="closeDialog" class="cancel">取消</el-button>
        <el-button
          type="primary"
          @click="saveReduceSet('formRef')"
          class="save"
          v-sdc
          >确定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import common from '../../kits/common'

export default {
  name: 'standardSetDetail',
  props: {
    scoreDimType: {
      type: String,
      default: '',
    },
    standardDetailId: {
      type: String,
      default: '',
    },
    standardSetInfo: {
      type: Object,
      default() {
        return {}
      },
    },
  },
  watch: {
    scoreDimType(newValue, oldValue) {
      this.getLevelList(this.scoreDimType)
    },
    standardDetailId(newValue, oldValue) {
      this.planList = JSON.parse(JSON.stringify(this.standardSetInfo.schemes))
      const formData = this.planList.find((v) => v.chooseStatus)
      if (formData) {
        formData.methods.forEach((v) => {
          v.reduceScore = v.score
        })
        this.standardSetForm = JSON.parse(JSON.stringify(formData))
        this.planId = this.standardSetForm.id
      }

      this.reduceForm.setList = []
      this.$refs['standardSetForm'].clearValidate()
    },
  },
  data() {
    var validateRate = (rule, value, callback) => {
      this.isAllowAdd = false
      let currentIndex = rule.field.split('.')[1] * 1
      let startCondition = 100
      let endCondition = 0
      if (currentIndex > 0) {
        startCondition =
          this.reduceForm.setList[currentIndex - 1].endCondition * 1
      }
      if (currentIndex < this.reduceForm.setList.length - 1) {
        endCondition =
          this.reduceForm.setList[currentIndex + 1].endCondition * 1
      }
      let reg = /^(([1-9]\d*)(\.\d{1,2})?|0\.([1-9]|\d[1-9])|0)$/
      if (!reg.test(value)) {
        callback(new Error('支持整数或两位小数'))
      } else if (value * 1 >= 100) {
        callback(new Error('右区间应小于100'))
      } else if (value * 1 >= startCondition && currentIndex > 0) {
        callback(new Error('应小于上一级右区间'))
      } else if (
        value * 1 <= endCondition &&
        currentIndex < this.reduceForm.setList.length - 1
      ) {
        callback(new Error('应大于下一级右区间'))
      } else {
        this.isAllowAdd = true
        callback()
      }
    }
    var validateCustomRate = (rule, value, callback) => {
      let condition = rule.field.split('.')[1]
      let inputIndex = rule.field.substring(8, 9)
      let startCondition =
        this.standardSetForm.methods[inputIndex].startCondition
      let endCondition = this.standardSetForm.methods[inputIndex].endCondition
      let reg = /^(([1-9]\d*)(\.\d{1,2})?|0\.([1-9]|\d[1-9])|0)$/
      if (!reg.test(value)) {
        callback(new Error('支持非负数或两位小数'))
      } else if (
        endCondition &&
        startCondition &&
        endCondition * 1 >= startCondition * 1
      ) {
        callback(new Error('左区间应大于右区间'))
      } else {
        this.isAllowAdd = true
        callback()
      }
    }
    var validateReduceScore = (rule, value, callback) => {
      let maxReduceScore = this.standardSetForm.score
      if (value * 1 > maxReduceScore) {
        return callback(new Error('应小于等于指标分值'))
      } else if (value * 1 <= 0) {
        return callback(new Error('应大于0'))
      } else {
        return callback()
      }
    }
    var validateScore = (rule, value, callback) => {
      let max = 0
      this.standardSetForm.methods.forEach((v) => {
        if (v.score) {
          max = max > v.score * 1 ? max : v.score * 1
        }
      })
      if (value * 1 > 100) {
        return callback(new Error('应小于等于100'))
      } else if (value * 1 <= 0) {
        return callback(new Error('应大于0'))
      } else if (
        value * 1 < max &&
        this.standardSetForm.evaluateCalculateType != 5
      ) {
        return callback(new Error('应不小于已配置扣分值'))
      } else {
        return callback()
      }
    }
    return {
      isShowUpdate: '',
      planId: '', //选中方案id
      selectLevel: [], //评级配置
      standardSetForm: {}, //方案详情
      standardRules: {
        evaluateStandard: [
          {
            required: true,
            message: '请输入评价标准',
            trigger: 'blur',
          },
        ],
        score: [
          {
            required: true,
            message: '请输入指标分值',
            trigger: 'blur',
          },
          {
            type: 'number',
            message: '分值为正整数',
            trigger: 'blur',
          },
          { validator: validateScore, trigger: 'blur' },
        ],
        reduceScore: [
          {
            required: true,
            message: '请输入扣分分值',
            trigger: 'blur',
          },
          { validator: validateReduceScore, trigger: 'blur' },
        ],
        startCondition: [
          {
            required: true,
            message: '区间值不能为空',
            trigger: 'blur',
          },
          { validator: validateCustomRate, trigger: 'blur' },
        ],
        endCondition: [
          {
            required: true,
            message: '区间值不能为空',
            trigger: 'blur',
          },
          { validator: validateCustomRate, trigger: 'blur' },
        ],
        gradeLevel: [
          {
            required: true,
            message: '请选择定级',
            trigger: 'change',
          },
        ],
        repairTips: [
          {
            required: true,
            message: '请输入修复方式',
            trigger: 'blur',
          },
        ],
        referenceRules: [
          {
            required: true,
            message: '请输入参考条例',
            trigger: 'blur',
          },
        ],
      },
      reduceVisible: false,
      isAllowAdd: true, //是否允许添加
      // 表单内容
      reduceForm: {
        setList: [],
      },
      reduceFormRules: {
        reduceScore: [
          {
            required: true,
            message: '请输入扣分分值',
            trigger: 'blur',
          },
          { validator: validateReduceScore, trigger: 'blur' },
        ],
        endCondition: [
          {
            required: true,
            message: '区间值不能为空',
            trigger: 'blur',
          },
          { validator: validateRate, trigger: 'blur' },
        ],
      },
    }
  },
  computed: {
    responsibility() {
      let enterpriseTypeEnum = ['建设单位', '施工单位', '分包单位']
      let scoreDimTypeEnum = ['0', '5', '10']
      let responsibilityArr = this.standardSetInfo.adviseBody.split(',')
      if (responsibilityArr.length === 3) {
        return '通用指标'
      } else if (responsibilityArr.length === 1) {
        let index = scoreDimTypeEnum.findIndex(
          (v) => v === responsibilityArr[0] + ''
        )
        return enterpriseTypeEnum[index]
      } else {
        let indexOne = scoreDimTypeEnum.findIndex(
          (v) => v === responsibilityArr[0] + ''
        )
        let indexTwo = scoreDimTypeEnum.findIndex(
          (v) => v === responsibilityArr[1] + ''
        )
        return (
          enterpriseTypeEnum[indexOne] + '和' + enterpriseTypeEnum[indexTwo]
        )
      }
    },
    isIndexOf() {
      let responsibilityArr = this.standardSetInfo.adviseBody.split(',')
      return responsibilityArr.indexOf(this.scoreDimType + '')
    },
  },
  created() {
    this.planList = JSON.parse(JSON.stringify(this.standardSetInfo.schemes))
    const formData = this.planList.find((v) => v.chooseStatus)
    if (formData) {
      formData.methods.forEach((v) => {
        v.reduceScore = v.score
      })
      this.standardSetForm = JSON.parse(JSON.stringify(formData))
      this.planId = this.standardSetForm.id
    }
    this.getLevelList(this.scoreDimType)
    this.isShowUpdate =
      this.$store.state.buttonLimitsArr.indexOf('standardSet:update') > -1
  },
  methods: {
    // 获取评级配置
    getLevelList(type) {
      return this.axios({
        method: 'post',
        url: 'api-ps/creditLevel/expand/getCreditLevelList',
        data: {
          type,
        },
      })
        .then((response) => {
          if (!response.data.hasError) {
            const results = response.data.result
            this.selectLevel = results
          } else {
            this.$message.error(response.data.errorMsg)
          }
        })
        .catch((error) => {
          if (error.response) {
            this.$message.error(error.response.data)
          }
        })
    },
    // 切换方案
    changePlan(id) {
      const formData = this.planList.find((v) => v.id === id)
      formData.methods.forEach((v) => {
        v.reduceScore = v.score
      })
      this.standardSetForm = JSON.parse(JSON.stringify(formData))
      this.reduceForm.setList = []
      this.$refs['standardSetForm'].clearValidate()
    },
    // 保存方案配置
    saveSet(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.standardSetForm.methods.forEach((v) => {
            v.score = v.reduceScore
          })
          if (this.standardSetForm.evaluateCalculateType === 5) {
            this.standardSetForm.methods.forEach((v) => {
              v.score = this.standardSetForm.score
            })
          }
          this.axios({
            method: 'post',
            url: '/api-ps/creditIndex/expand/update',
            data: {
              type: this.scoreDimType,
              indexId: this.standardDetailId,
              schemeId: this.planId,
              chooseStatus: 1,
              evaluateStandard: this.standardSetForm.evaluateStandard,
              score: this.standardSetForm.score,
              referenceRules: this.standardSetForm.referenceRules,
              repairTips: this.standardSetForm.repairTips,
              methodList: JSON.stringify(this.standardSetForm.methods),
            },
          })
            .then((response) => {
              if (response.data.hasError) {
                this.$message.error(response.data.errorMsg)
              } else {
                this.$message.success('保存成功')
                this.$emit('updateStandardList', this.scoreDimType)
              }
            })
            .catch((error) => {
              if (error.response) {
                this.$message.error(error.response.data)
              }
            })
        } else {
          this.$message.error('请按照提示规则输入内容!')
          return false
        }
      })
    },
    // 扣分区间dialog
    reduceSet() {
      if (this.standardSetForm.score) {
        if (
          this.standardSetForm.methods.length > 1 ||
          (this.standardSetForm.methods[0].startCondition &&
            this.standardSetForm.methods[0].endCondition)
        ) {
          this.reduceForm.setList = JSON.parse(
            JSON.stringify(this.standardSetForm.methods)
          )
        }
        this.reduceVisible = true
      } else {
        this.$message.error('请先输入指标分值')
      }
    },
    // 添加区间
    addLevel() {
      if (
        this.reduceForm.setList.length &&
        (!this.reduceForm.setList[this.reduceForm.setList.length - 1]
          .endCondition ||
          !this.isAllowAdd ||
          this.reduceForm.setList[this.reduceForm.setList.length - 1]
            .endCondition *
            1 <=
            0)
      ) {
        this.$message.error('请先输入上一等级区间值且区间值最小为0')
        return
      } else {
        let addObj = {}
        addObj.score = ''
        addObj.startCondition = 100
        addObj.endCondition = null
        if (this.reduceForm.setList.length > 0) {
          addObj.startCondition = this.reduceForm.setList[
            this.reduceForm.setList.length - 1
          ].endCondition
            ? this.reduceForm.setList[this.reduceForm.setList.length - 1]
                .endCondition
            : null
        }
        this.reduceForm.setList.push(addObj)
      }
    },
    // 删除区间
    delRate(index) {
      let updateList = JSON.parse(JSON.stringify(this.reduceForm.setList))
      updateList.splice(index, 1)
      if (index <= updateList.length - 1) {
        updateList[index].startCondition = updateList[index - 1].endCondition
      }
      this.reduceForm.setList = JSON.parse(JSON.stringify(updateList))
    },
    // 修改区间分数
    changeRate(index) {
      if (index < this.reduceForm.setList.length - 1) {
        this.reduceForm.setList[index * 1 + 1].startCondition =
          this.reduceForm.setList[index].endCondition
      }
    },
    // 保存区间
    saveReduceSet(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (this.reduceForm.setList.length > 0) {
            this.reduceVisible = false
            // let setList = [];
            let setInfo = {}
            if (
              this.standardSetForm.methods.length >
              this.reduceForm.setList.length
            ) {
              let sliceArr = this.standardSetForm.methods.slice(
                0,
                this.reduceForm.setList.length - 1
              )
              this.standardSetForm.methods = JSON.parse(
                JSON.stringify(sliceArr)
              )
            }
            for (let i = 0; i < this.reduceForm.setList.length; i++) {
              if (i < this.standardSetForm.methods.length) {
                this.standardSetForm.methods[i].reduceScore =
                  this.standardSetForm.methods[i].score =
                    this.reduceForm.setList[i].reduceScore
                this.standardSetForm.methods[i].startCondition =
                  this.reduceForm.setList[i].startCondition
                this.standardSetForm.methods[i].endCondition =
                  this.reduceForm.setList[i].endCondition
              } else {
                setInfo.reduceScore = setInfo.score =
                  this.reduceForm.setList[i].reduceScore
                setInfo.startCondition =
                  this.reduceForm.setList[i].startCondition
                setInfo.endCondition = this.reduceForm.setList[i].endCondition
                this.standardSetForm.methods.push(
                  JSON.parse(JSON.stringify(setInfo))
                )
              }
            }
          } else {
            this.$message.error('请先添加区间')
            return false
          }
        } else {
          this.$message.error('请按照提示规则输入内容!')
          return false
        }
      })
    },
    // 关闭dialog
    closeDialog() {
      this.reduceVisible = false
      this.$refs['formRef'].clearValidate()
      if (
        this.standardSetForm.methods.length > 1 ||
        (this.standardSetForm.methods[0].startCondition &&
          this.standardSetForm.methods[0].endCondition)
      ) {
        this.reduceForm.setList = JSON.parse(
          JSON.stringify(this.standardSetForm.methods)
        )
      } else {
        this.reduceForm.setList = []
      }
    },
  },
}
</script>

<style scoped lang="less">
.standardSetDetail {
  .advice {
    height: 36px;
    width: 100%;
    padding-left: 12px;
    line-height: 36px;
    font-size: 14px;
    color: #41a500;
    background: #eaf3e6;
    .adviceFont {
      color: #338f05;
    }
  }
  .notAdvice {
    height: 36px;
    width: 100%;
    padding-left: 12px;
    line-height: 36px;
    font-size: 14px;
    background: #fdf6ec;
    color: #f2ad2f;
    .notAdviceFont {
      color: #f2ad2f;
    }
  }
  .el-icon-info {
    position: relative;
    top: 3px;
    font-size: 22px;
  }
  .standardSetContent {
    padding-left: 84px;
    padding-top: 45px;
    /deep/ .el-form-item__label {
      font-size: 14px;
      color: #333333;
      text-align: right;
    }
    /deep/ .el-radio__inner {
      width: 16px;
      height: 16px;
      // &:hover {
      //     border-color: #009588;
      // }
    }
    /deep/ .el-radio__input.is-checked .el-radio__inner {
      // border-color: #009588;
      background: #ffffff;
      &::after {
        width: 8px;
        height: 8px;
        // background: #009588;
      }
    }
    /deep/.el-radio__input.is-checked + .el-radio__label {
      font-size: 14px;
      // color: #009588;
      letter-spacing: 0;
      text-align: left;
    }
    .explain {
      font-size: 14px;
      color: #666666;
      /deep/ .el-button {
        height: 36px;
        // width: 110px;
        // background: #009588;
        font-size: 14px;
        color: #ffffff;
        border: none;
        // .iconshezhi {
        //     margin-right: 6px;
        //     margin-left: -4px;
        //     position: relative;
        //     top: -1px;
        // }
        // span {
        //     position: relative;
        //     top: -2px;
        // }
      }
      .getExplain {
        line-height: 24px;
      }
      /deep/.el-input {
        width: 110px;
        height: 36px;
        input {
          text-align: center;
        }
      }
      .everyRate {
        .subLevel {
          display: inline-block;
          width: 75px;
          /deep/.el-input {
            width: 75px;
          }
        }
        .score {
          display: inline-block;
          text-align: center;
        }
        /deep/.el-form-item__error {
          width: 150px;
        }
      }
    }
    .setInfo {
      line-height: 58px;
      font-size: 14px;
      color: #4c4c4c;
      margin-left: 10px;
    }
  }
  /deep/ .el-textarea .el-input__count {
    background: none;
  }
  /deep/ .el-input input {
    text-align: center;
  }
}
.dialogForm {
  // .dialog-footer {
  //     /deep/ .el-button {
  //         height: 36px;
  //         width: 76px;
  //         background: #009588;
  //         font-size: 14px;
  //         color: #ffffff;
  //         border: none;
  //     }
  // }
  /deep/.el-input {
    width: 110px;
    height: 36px;
    input {
      text-align: center;
    }
  }
  // /deep/.el-dialog__footer {
  //     height: 66px;
  //     background: #f0f4f7;
  //     padding-bottom: 0;
  // }
  /deep/ .el-dialog__body {
    max-height: 500px;
  }
  .titleLevel {
    display: inline-block;
    width: 110px;
    margin-right: 20px;
    text-align: center;
  }
  .subLevel {
    display: inline-block;
    width: 110px;
  }
  .titleScore {
    display: inline-block;
    width: 370px;
    text-align: center;
    margin-right: 12px;
  }
  .titleAction {
    display: inline-block;
    width: 30px;
    position: relative;
    right: 0;
    text-align: center;
  }
  .titleAction:hover {
    cursor: pointer;
  }
  .score {
    display: inline-block;
    text-align: center;
  }
  .addLevel {
    height: 32px;
    text-align: center;
    line-height: 30px;
    font-size: 14px;
    color: #a3a3a3;
    border: 1px dashed #dee5f4;
  }
  .addLevel:hover {
    cursor: pointer;
    // color: #409eff;
    // border-color: #409eff;
  }
  .dialogBtn {
    position: relative;
    top: 6px;
  }
}
</style>
